package cos.android.tim;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import cos.android.tim.R;
import cos.android.tim.utils.Utils;

public class InitScreen extends Activity implements OnClickListener {

	Button play;
	Button editor;
	Button salir;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);

		setContentView(R.layout.initscreen);

		play = (Button) findViewById(R.id.playButton);
		editor = (Button) findViewById(R.id.editorButton);
		salir = (Button) findViewById(R.id.salirButton);

		play.setOnClickListener(this);
		editor.setOnClickListener(this);
		salir.setOnClickListener(this);

	}

	@Override
	public void onClick(View v) {

		Intent i = null;
		switch (v.getId()) {

		case (R.id.playButton):
			i = new Intent(this, SelectWorld.class);
			break;
		case (R.id.editorButton):
			i = new Intent(this, Tim.class);
			i.putExtra("editor", true);
			break;
		case (R.id.salirButton):
			finish();
			return;
		}
		startActivity(i);
		finish();
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		super.onCreateOptionsMenu(menu);

		menu.add(Menu.NONE, Utils.MENU_EXIT, Menu.NONE, R.string.salirStr);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case Utils.MENU_EXIT:
			finish();
			return true;
		}
		return false;
	}
}
